package com.dobbinsoft.iotechn.device.api.open;

import com.dobbinsoft.iotechn.core.annotation.HttpMethod;
import com.dobbinsoft.iotechn.core.annotation.HttpOpenApi;
import com.dobbinsoft.iotechn.core.annotation.HttpParam;
import com.dobbinsoft.iotechn.core.annotation.HttpParamType;
import com.dobbinsoft.iotechn.core.annotation.param.NotNull;
import com.dobbinsoft.iotechn.core.annotation.param.Range;
import com.dobbinsoft.iotechn.core.exception.ServiceException;
import com.dobbinsoft.iotechn.core.model.Page;
import com.dobbinsoft.iotechn.device.dto.DeviceDevDTO;
import com.dobbinsoft.iotechn.device.dto.DeviceDataDTO;

import java.util.List;

/**
 * Description:
 * User: rize
 * Date: 2020/6/21
 * Time: 15:21
 */
@HttpOpenApi(group = "device.dev", description = "为developer提供设备管理服务")
public interface DeviceDevService {

    @HttpMethod(description = "创建一个设备")
    public String create(
            @NotNull @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "搜索设备")
    public Page<DeviceDevDTO> list(
            @HttpParam(name = "pageNo", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer pageNo,
            @Range(min = 1, max = 100) @HttpParam(name = "pageSize", type = HttpParamType.COMMON, description = "页码长度", valueDef = "20") Integer pageSize,
            @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
            @HttpParam(name = "accessKeyId", type = HttpParamType.COMMON, description = "序列") String accessKeyId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    /**
     * 此接口只能从DB中获取数据，此数据属于冷数据，不具有实时性，若需要实时数据，应该从WS接口中获取
     * @param deviceId
     * @param developerId
     * @return
     * @throws ServiceException
     */
    @HttpMethod(description = "数据点列表")
    public List<DeviceDataDTO> listData(
            @NotNull @HttpParam(name = "deviceId", type = HttpParamType.COMMON, description = "设备Id") Long deviceId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "显示设备密钥")
    public String showAccessSecret(
            @NotNull @HttpParam(name = "deviceId", type = HttpParamType.COMMON, description = "设备Id") Long deviceId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "删除设备")
    public String delete(
            @NotNull @HttpParam(name = "deviceId", type = HttpParamType.COMMON, description = "设备Id") Long deviceId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

}
